package com.itheima.d2_buffered_stream;

import java.io.*;

/*
    目标：观察原始流和缓冲流的性能。
 */
public class TimeTest4 {
    public static void main(String[] args) {
        copy();
    }

    private static void copy() {
        try (FileInputStream fis = new FileInputStream("D:\\p图\\哥特女王\\IMG_7953_proc.jpg");
             BufferedInputStream bis = new BufferedInputStream(fis);
             FileOutputStream fos = new FileOutputStream("IMG.jpg");
             BufferedOutputStream bos = new BufferedOutputStream(fos)) {
            int len;
            byte[] bytes = new byte[1024];
            while((len = bis.read(bytes)) != -1){
                bos.write(bytes, 0,len);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    private static void copy1() {
        try (FileInputStream fis = new FileInputStream("D:\\p图\\哥特女王\\IMG_7953_proc.jpg");

             FileOutputStream fos = new FileOutputStream("IMG.jpg")){

            int len= 0;
            byte[] bytes = new byte[1024];
            while((len = fis.read(bytes)) != -1){
                fos.write(bytes, 0,len);
            }
        } catch (FileNotFoundException ex) {
            throw new RuntimeException(ex);
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }
    }
}










